package com.spring.cloud.seata.controller;

import com.spring.cloud.seata.domain.Order;
import com.spring.cloud.seata.service.IOrderService;
import com.spring.cloud.seata.vo.ResultVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zhangtengfei
 * @date 2021/10/18 11:21
 */

@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private IOrderService orderService;

    /**
     * 创建订单
     */
    @PostMapping("/create")
    public ResultVO create(Order order) {
        orderService.createOrder(order);

        ResultVO resultVo = new ResultVO();
        resultVo.setMsg("创建订单成功");
        resultVo.setSuccess(true);
        resultVo.setData("订单ID:" + order.getId());
        return resultVo;
    }
}
